package comWorld.blog;

import java.util.Date;

import webManage.UrlTools;

import com.gjs.tools.Date.DateUtil;

import comWorld.user.UserInfo;

public class BlogLog {
	private int blogId = 0;
	private int userId = 0;
	private String userHome;
	private String userName;
	private String userHeadImage;
	private String blogHome;
	private String title;
	private String type;
	private String writeTime;
	private String writeDateInterval;
	private int commentCount;
	private int readCount;
	private int praiseCount;
	
	public BlogLog() {
		
	}

	public int getBlogId() {
		return blogId;
	}

	public void setBlogId(int blogId) {
		this.blogId = blogId;
		setHome();
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
		setHome();
	}

	public String getUserHome() {
		return userHome;
	}

	public void setUserHome(String userHome) {
		this.userHome = userHome;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserHeadImage() {
		return userHeadImage;
	}

	public void setUserHeadImage(String userHeadImage) {
		if (userHeadImage == null || userHeadImage.length() == 0) 
			userHeadImage = UserInfo.DEFAULHEADPATH;
		this.userHeadImage = userHeadImage;
	}

	public String getBlogHome() {
		return blogHome;
	}

	public void setBlogHome(String blogHome) {
		this.blogHome = blogHome;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getWriteTime() {
		return writeTime;
	}

	public void setWriteTime(String writeTime) {
		this.writeTime = writeTime;
		String interval = DateUtil.getTimeInterval(DateUtil.parseDate(writeTime, DateUtil.DATESTRFORMAT), new Date());
		setWriteDateInterval(interval);
	}

	public String getWriteDateInterval() {
		return writeDateInterval;
	}

	public void setWriteDateInterval(String writeDateInterval) {
		this.writeDateInterval = writeDateInterval;
	}

	public int getCommentCount() {
		return commentCount;
	}

	public void setCommentCount(int commentCount) {
		this.commentCount = commentCount;
	}

	public int getReadCount() {
		return readCount;
	}

	public void setReadCount(int readCount) {
		this.readCount = readCount;
	}

	public int getPraiseCount() {
		return praiseCount;
	}

	public void setPraiseCount(int praiseCount) {
		this.praiseCount = praiseCount;
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	private void setHome() {
		if (blogId != 0 && userId != 0) {
			userHome = UrlTools.WEBROOTURL + "u/" + userId + "/";
			blogHome = userHome + "blog/" + blogId;
		}
	}
}
